import request from "@/utile/request";
import type { seachvaluetype } from "@/path/video/type";
import type {
  loginback,
  banderdatatype,
  addbanderdatatype,
  getshopuser,
  getordertype,
} from "./type";
enum api {
  login = "/main/user/login",
  getbander = "/main/bander",
  assbander = "/main/bander/add",
  updatabnader = "/main/bander/updata",
  delbander = "/main/bander/del",
  getshopuser = "/shopper/req/getuser",
  deleteshopper = "/shopper/req/delete",
  freezeapi = "/shopper/req/freeze",
  unfreezeapi = "/shopper/req/unfreeze",
  maingetuser = "/main/user/getuser",
  deleuser = "/main/user/dele",
  getshop = "/main/shop/get",
  succshop = "/main/shop/succ",
  closeshop = "/main/shop/close",
  outshop = "/main/shop/out",
  getorder = "/main/order/getorder",
  seahorder = "/main/order/seachorder",
  delorder = "/main/order/delorder",
  getproduct = "/main/product/getproduct",
  setproductstatus = "/main/product/setproductstatus",
  getuserandpris = "/main/product/getuserandpri",
}
export const getlogin = (data) =>
  request.get<any, loginback>(api.login, { params: { ...data } });
export const getbander = () => request.get<any, banderdatatype>(api.getbander);
export const addbandersend = (data: any) =>
  request.post<any, addbanderdatatype>(api.assbander, data);
export const editbandersend = (data: any) =>
  request.post<any, any>(api.updatabnader, data);
export const delbanders = (id: any) =>
  request.get<any, any>(api.delbander, { params: { id } });
export const getshopperuser = (
  offset: number,
  limit: number,
  findkey: object
) =>
  request.get<any, getshopuser>(api.getshopuser, {
    params: { offset, limit, findkey: JSON.stringify(findkey) },
  });
export const deshopper = (id: number) =>
  request.post<any, addbanderdatatype>(api.deleteshopper, { id });
export const freezereq = (id: number) =>
  request.post<any, addbanderdatatype>(api.freezeapi, { id });
export const unfreezereq = (id: number) =>
  request.post<any, addbanderdatatype>(api.unfreezeapi, { id });
export const getuser = (
  limit: number,
  offset: number,
  name: string,
  phone: string
) =>
  request.get<any, any>(api.maingetuser, {
    params: { limit, offset, name, phone },
  });
export const deleuser = (id: number) =>
  request.get<any, addbanderdatatype>(api.deleuser, { params: { id } });
export const getshopdata = (
  offset: number,
  limit: number,
  seachvalue: seachvaluetype
) =>
  request.get<any, any>(api.getshop, {
    params: { offset, limit, seach: JSON.stringify(seachvalue) },
  });

export const shopclose = (userid: number, id: number) =>
  request.post<any, addbanderdatatype>(api.closeshop, { id, userid });
export const shopout = (userid: number, id: number) =>
  request.post<any, addbanderdatatype>(api.outshop, { id, userid });
export const shopsucc = (userid: number, id: number) =>
  request.post<any, addbanderdatatype>(api.succshop, { id, userid });
export const getorderdata = () => request.get<any, getordertype>(api.getorder);
export const seahorderorderdata = (data) =>
  request.post<any, getordertype>(api.seahorder, { ...data });
export const delorders = (id) =>
  request.post<any, addbanderdatatype>(api.delorder, { id });

export const getproducts = () => request.get<any, any>(api.getproduct);
export const getuserandpriss = () => request.get<any, any>(api.getuserandpris);
export const setproductstatus = (id, status) =>
  request.post<any, any>(api.setproductstatus, { id, status });
